import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        List<Integer> list = new ArrayList<>();
        //反射拿到类里面的方法
        Method method = list.getClass().getMethod("add",Object.class);
        method.invoke(list,"hello");
        System.out.println(list);
    }
}
